package com.liujit.standard.basis.generator.action.model;

import lombok.Getter;

/**
 * @Description db字段类型映射
 * @Author LiuJun
 * @Date 2020/8/13 5:32 下午
 */
@Getter
public enum DbColumnType {

    DECIMAL("decimal", "BigDecimal", "DECIMAL"), TIME("time", "Date", "TIME"), DATE("date", "Date", "DATE"), LONG_VARCHAR("longtext", "String",
            "LONGVARCHAR"), BIGINT("bigint", "Long", "BIGINT"), VARCHAR("varchar", "String", "VARCHAR"), SMALLINT(
                    "smallint", "Short", "SMALLINT"), TIMESTAMP("datetime", "Date", "TIMESTAMP"), INTEGER("integer",
                            "Integer", "INTEGER"), INT("int", "Integer", "INTEGER"), JSON("json", "Object", "OTHER");

    private final String dataType;

    private final String type;

    private final String jdbcType;

    DbColumnType(String dataType, String type, String jdbcType) {
        this.dataType = dataType;
        this.type = type;
        this.jdbcType = jdbcType;
    }

    public static DbColumnType get(String dataType) {
        for (DbColumnType ele : values()) {
            if (ele.getDataType().equals(dataType)) {
                return ele;
            }
        }
        return null;
    }
}
